#include<iostream>
using namespace std;
int sumI(int n)
{
	int s=0;
	for (int i = 0; i <= n ; i++)
	{
		s= s+i;
	}
	return s;
}

int sumR(int i, int n)
{
	if(i==n)
		return n;
	else 
		return i+sumR(i+1, n);
}

int sumR2(int n)
{
	if(n==0)
		return 0;
	else
		return n+sumR2(n-1);
}

int main()
{
	cout << sumR(1,9) << endl;
	cout << sumI(9) << endl;
	cout << sumR2(9) << endl;

	system("PAUSE");
	return 0;
}